package com.example.mykotilin.paging2.repository.inMemory.byPage

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.example.mykotilin.paging2.RedditApi
import com.example.mykotilin.paging2.repository.RedditPostRepository
import com.example.mykotilin.paging2.vo.RedditPost
import kotlinx.coroutines.flow.Flow

class InMemoryByPageKeyRepository(
    private val redditApi: RedditApi
) : RedditPostRepository{
    override fun postOfSubreddit(subReddit: String, pageSize: Int) = Pager(
        PagingConfig(pageSize)
    ){
        PageKeyedSubredditPagingSource(
            redditApi = redditApi,
            subredditName = subReddit
        )
    }.flow
}